-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add rustc --drawing to use Unicode line drawing characters for span output #21406
Conversation
With some other cleanup at the use sites.
…utput I bet we can find other uses for these sorts of characters in clarifying type errors, etc. This is marked as a "stable" flag for consistency with --color. However we should reconsider both of them as part of rust-lang#19051. For these features to be conveniently available with Cargo, we may want to use environment variables or a config file.
(rust_highfive has picked a reviewer for you, use r? to override) |
This is so cool! |
This looks great, I'm just a bit unclear on what the story is regarding adding new flags (as you call out). Have we not even started on finalizing the set of flags yet? Should this be a |
I agree with @nikomatsakis that this should probably be unstable for now, you can do so by calling |
Shall I mark |
For I believe the plan was to consider |
In that case, how about an environment variable instead? e.g.
This would not be subject to stability guarantees, on the grounds that it can only affect the formatting of compiler output. Correspondingly, unrecognized syntax in the environment variable would be non-fatal. Then we could get rid of |
I would personally consider "magic environment variables" to be within the realm of stability guarantees we have to worry about. It may not actively break code in this case but we may wish to rename the environment variable or rename It is an interesting idea though for something that we don't currently look at much. It's definitely a flexible format that we can ignore old/stale values from. |
We're not generally making stability guarantees about the exact formatting of error messages, are we? I hope we can fix unclear wordings and stuff like that on each 1.x release. |
Yeah I would expect us to be able to reformat error messages at will. |
So I think it's okay for unstable environment variables to affect the output formatting. Although a stable flag to disable it would be good. |
I think we should autodetect Unicode support, just as we do for |
It's not just about Unicode support, but about whether your terminal font includes those characters. I don't know any way to auto-detect that. |
I think autodetection accuracy is less important than a way to workaround when it misbehaves. For example, GCC does misbehave in TERM=linux, but LANG=C gcc is easy enough. |
@brson this might offer a way to make the "downward errors" in your multi-line spans more clearly indicated |
@kmcallister please do not make the control for this solely available via environment variables. I don't mind if you provide that in addition to (unstable) command line options, but I like the option of using just command line options when I can, e.g. in my scripts and what not. Plus they are more self-documenting (in terms of being reported by |
OK, so it seems like consensus is:
Do we have a (stable) command-line flag for saying "plain ASCII output please"? |
I propose we restrict ourselves to Windows Glyph List 4 for Unicode characters, in order to have the widest possible font support. It is suboptimal, but in the absence of ways to detect support, the lowest common denominator is the way to go. Incidentally, that means this patch should use different box drawing characters. |
I can live with WGL4. I'm happy to have at least some basis for thinking these glyphs are widely available.
Let's enable line drawing automatically when we're writing to a terminal and We could also use line drawing when writing to a file. My main concern here is that web servers tend to erroneously serve "plain text" files with a Windows-1252 encoding header.
I'll add an unstable one. Then we can bikeshed the name in an RFC. Whatever mechanism we add should integrate with |
Related: should we switch |
What exactly would it take to un-stabilize |
You should request for color, obviously. |
@kmcallister i don't know if it requires an RFC to destabilize something like |
I would be fine moving |
New proposal:
|
@pnkfelix: Does the new proposal satisfy your requirements? There's a command-line flag to disable fancy output, but no flag to enable it, because in my mind this is more of an ambient, per-user UI configuration. Still, we can add such flags if the need becomes clear. |
@kmcallister yeah this is probably fine; I cannot offhand think of a strong reason to push for the flags, other than my own inability to remember the exact shell syntax for setting env variables in various contexts. Thanks for asking. |
I'm not interested in finishing this PR. Let me know if I should close it or what. If someone else wants to take it over, that's great :) |
I might. Maybe. No time now. |
Closing due to inactivity, but see #24387. |
I bet we can find other uses for these sorts of characters in clarifying type errors, etc.
This is marked as a "stable" flag for consistency with
--color
. However we should reconsider both of them as part of #19051. For these features to be conveniently available with Cargo, we may want to use environment variables or a config file.